//-------------------------------------------------------------------------------//

#include "globals.h"
#include "adGame.h"

adGame abstractDanmaku;

//-------------------------------------------------------------------------------//
// FrameFunc() - This is just a hack to call our game's frame function.
//-------------------------------------------------------------------------------//
bool staticFrameFunc()
{
    return abstractDanmaku.Update();
}

//-------------------------------------------------------------------------------//
// staticRenderFunc() - This is just a hack to call our game's render function.
//-------------------------------------------------------------------------------//
bool staticRenderFunc()
{
    abstractDanmaku.Render();
    return false;
}

//-------------------------------------------------------------------------------//
// WinMain() - Our main entry point, initiates HGE.
//-------------------------------------------------------------------------------//
int WINAPI WinMain ( HINSTANCE, HINSTANCE, LPSTR, int )
{
    abstractDanmaku = adGame();

    // create HGE pointer, for every hgeCreate, call hge->release
    HGE* hge = hgeCreate ( HGE_VERSION );
    hge->System_SetState ( HGE_FRAMEFUNC, staticFrameFunc );
    hge->System_SetState ( HGE_RENDERFUNC, staticRenderFunc );
    abstractDanmaku.Initiate ( "data/settings.xml" );

    if ( hge->System_Initiate() == true )
    {
        // load sprites, textures, and other things after System_Initiate()
        abstractDanmaku.Setup();

        hge->System_Start();

        // cleanup sprites, textures, and other after the main loop has finished
        abstractDanmaku.Cleanup();
    }
    else
        MessageBox ( NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL );

    abstractDanmaku.Destroy();

    hge->System_Shutdown();
    hge->Release();

    return 0;
}

//-------------------------------------------------------------------------------//
